package com.zhm.demo.postgresql.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.zhm.demo.postgresql.config.PGJsonbTypeHandler;
import lombok.Data;
import org.apache.ibatis.type.JdbcType;

import java.time.LocalDateTime;
import java.util.Map;

@Data
@TableName("iot_uni_data_log")
@JsonIgnoreProperties(ignoreUnknown = true)
public class IotUniDataLog {

    @TableId(type = IdType.AUTO)
    private String id;
    public static final String KEY_ID = "id";

    private LocalDateTime date;
    public static final String KEY_DATE = "date";

    private Long ts;
    public static final String KEY_TS = "ts";

    /**
     * 协议版本
     */
    @TableField("protocol_key")
    private String protocolKey;
    public static final String KEY_PROTOCOL_KEY = "protocolKey";

    /**
     * 设备编码
     */
    private String sn;
    public static final String KEY_SN = "sn";

    /**
     * 功能
     */
    protected String func;
    public static final String KEY_FUNC = "func";

    protected String action;
    public static final String KEY_ACTION = "action";

    private String topic;
    public static final String KEY_TOPIC = "topic";

    @TableField("content_type")
    private String contentType;
    public static final String KEY_CONTENT_TYPE = "contentType";


    private byte[] contents;
    public static final String KEY_CONTENTS = "contents";

    @TableField(value = "param_map", jdbcType = JdbcType.OTHER, typeHandler = PGJsonbTypeHandler.class)
    private Map<String, Object> paramMap;
    public static final String KEY_PARAM_MAP = "paramMap";


}
